<template>
  <a-card :loading="loading" hoverable :bordered="false">
    <div class="card-header">
      <div class="meta">
        <div class="card-header-title">
          <slot name="title">{{ title }}</slot>
        </div>
        <div class="card-header-action">
          <slot name="action"></slot>
        </div>
      </div>
      <div class="total">
        <slot name="total">
          <span>{{ typeof total === 'function' && total() || total }}</span>
        </slot>
      </div>
    </div>
    <div class="card-content">
      <div class="card-fix">
        <slot></slot>
      </div>
    </div>
    <div class="card-footer">
      <div class="field">
        <slot name="footer"></slot>
      </div>
    </div>
  </a-card>
</template>

<script>
export default {
  name: 'ChartCard',
  props: {
    title: {
      type: String,
      default: ''
    },
    total: {
      type: [Function, Number, String],
      required: false,
      default: null
    },
    loading: {
      type: Boolean,
      default: false
    }
  }
}
</script>

<style lang="less" scoped>
.card-header{
  .meta{
    overflow: hidden;
    .card-header-title{
      float:left
    }
    .card-header-action{
      float:right
    }
  }
  .total{
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-all;
    white-space: nowrap;
    color: #000;
    margin-top: 4px;
    margin-bottom: 0;
    font-size: 30px;
    line-height: 38px;
    height: 38px;
  }
}
.card-content{
  margin-bottom: 12px;
    position: relative;
    height: 46px;
    width: 100%;

    .card-fix{
      position: absolute;
      left:0;
      bottom:0;
      width: 100%;
    }
}
.card-footer{
  border-top: 1px solid #e8e8e8;
    padding-top: 9px;
    margin-top: 8px;

    .field{
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
    }
}
</style>
